Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle valid JSON messages which are not GreengrassLogMessages #214

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

MikeDombo
Copy link
Member

Issue #, if available:
#213

Description of changes:
Handle the case where log level is null in deserialized JSON format logs. Log level is never supposed to be null, so this should only be possible if someone is not using the Greengrass logger (waiting for more customer info to determine this). Regardless, we should handle the case properly. Here we default to INFO level if the log level parsed from JSON is null or empty.

Why is this change necessary:

How was this change tested:
Updated existing test file with a null log level and verified that test fails without the fix and that it passes with the fix.

Any additional information or context required to review the change:

Checklist:

  • Updated the README if applicable
  • Updated or added new unit tests
  • Updated or added new integration tests
  • Updated or added new end-to-end tests

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@MikeDombo MikeDombo changed the title fix: handle null log level in deserialized json fix: handle valid JSON messages which are not GreengrassLogMessages Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (e18e5cf) 86.35% compared to head (73b73c7) 85.36%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #214      +/-   ##
==========================================
- Coverage   86.35%   85.36%   -0.99%     
==========================================
  Files          13       13              
  Lines        1033     1052      +19     
  Branches      106      109       +3     
==========================================
+ Hits          892      898       +6     
- Misses         87       96       +9     
- Partials       54       58       +4     
Flag Coverage Δ
integration 69.10% <4.54%> (-1.18%) ⬇️
unit 85.36% <27.27%> (-0.99%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../aws/greengrass/logmanager/model/LogFileGroup.java 75.82% <0.00%> (ø)
...m/aws/greengrass/logmanager/LogManagerService.java 87.10% <33.33%> (+0.12%) ⬆️
...a/com/aws/greengrass/logmanager/model/LogFile.java 75.34% <0.00%> (-3.23%) ⬇️
...ass/logmanager/CloudWatchAttemptLogsProcessor.java 86.48% <33.33%> (-3.69%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

Unit Tests Coverage Report

File Coverage Lines Branches
All files 77% 84% 71%
com.aws.greengrass.logmanager.services.DiskSpaceManagementService 71% 83% 60%
com.aws.greengrass.logmanager.CloudWatchLogsUploader 90% 97% 83%
com.aws.greengrass.logmanager.LogManagerService 68% 81% 55%
com.aws.greengrass.logmanager.LogManagerService$CurrentProcessingFileInformation 79% 89% 68%
com.aws.greengrass.logmanager.PositionTrackingBufferedReader 86% 87% 86%
com.aws.greengrass.logmanager.CloudWatchAttemptLogsProcessor 88% 89% 86%
com.aws.greengrass.logmanager.util.ConfigUtil 85% 85% 85%
com.aws.greengrass.logmanager.util.CloudWatchClientFactory 53% 53% 0%
com.aws.greengrass.logmanager.model.CloudWatchAttemptLogInformation 100% 100% 0%
com.aws.greengrass.logmanager.model.EventType 100% 100% 0%
com.aws.greengrass.logmanager.model.ComponentType 100% 100% 0%
com.aws.greengrass.logmanager.model.ProcessingFiles 68% 80% 56%
com.aws.greengrass.logmanager.model.LogFile 85% 78% 92%
com.aws.greengrass.logmanager.model.LogFileGroup 70% 75% 64%

Minimum allowed coverage is 65%

Generated by 🐒 cobertura-action against 73b73c7

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

Integration Tests Coverage Report

File Coverage Lines Branches
All files 68% 76% 60%
com.aws.greengrass.logmanager.services.DiskSpaceManagementService 47% 55% 40%
com.aws.greengrass.logmanager.CloudWatchLogsUploader 42% 42% 41%
com.aws.greengrass.logmanager.LogManagerService 84% 93% 74%
com.aws.greengrass.logmanager.LogManagerService$CurrentProcessingFileInformation 46% 55% 37%
com.aws.greengrass.logmanager.PositionTrackingBufferedReader 72% 82% 63%
com.aws.greengrass.logmanager.CloudWatchAttemptLogsProcessor 67% 73% 61%
com.aws.greengrass.logmanager.util.ConfigUtil 48% 61% 35%
com.aws.greengrass.logmanager.util.CloudWatchClientFactory 100% 100% 0%
com.aws.greengrass.logmanager.model.CloudWatchAttemptLogInformation 100% 100% 0%
com.aws.greengrass.logmanager.model.EventType 100% 100% 0%
com.aws.greengrass.logmanager.model.ComponentType 100% 100% 0%
com.aws.greengrass.logmanager.model.ProcessingFiles 84% 93% 75%
com.aws.greengrass.logmanager.model.LogFile 40% 46% 34%
com.aws.greengrass.logmanager.model.LogFileGroup 64% 74% 53%

Minimum allowed coverage is 58%

Generated by 🐒 cobertura-action against 73b73c7

String totalLogNumbers = "50";
String fileSizeBytes = "1024";
String fileSizeUnit = "KB";
String componentName = "com.aws.greengrass.artifacts.LogGenerator";
String activeFileName = logFileName + "." + logFileExtention;
String activeFileName = logFileName + ".log";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we moving from a variable to a hard coded string?

Copy link
Member Author

@MikeDombo MikeDombo Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test (for a test), variable wasn't a variable but a constant.

K-AWS
K-AWS previously approved these changes Oct 26, 2023
Copy link

@K-AWS K-AWS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit about the ".log" string

@MikeDombo MikeDombo requested a review from K-AWS October 26, 2023 20:40
@@ -17,19 +16,18 @@ public class LogGeneratorTest {
@TempDir
static Path tempPath;
String logFileName = "localtest";
String logFileExtention = "log";
String logWriteFreqSeconds = "0.1";
String logWriteFreqMs = "100";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is someone going to think this is milliseconds and not messages per second?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is milliseconds. 0.1 seconds is 100 milliseconds.

@MikeDombo MikeDombo merged commit ad0abce into main Oct 27, 2023
6 of 8 checks passed
@MikeDombo MikeDombo deleted the fix-null-level branch October 27, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants